package com.edu.neusoft.student.service;

import com.edu.neusoft.student.util.RedisStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.edu.neusoft.student.domain.Student;
import com.edu.neusoft.student.mapper.StudentMapper;

import java.util.List;

@Service
public class StudentService{

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private RedisStudentService redisStudentService;

    public int deleteByPrimaryKey(Integer studentId) {
        return studentMapper.deleteByPrimaryKey(studentId);
    }

    
    public int insert(Student record) {
        return studentMapper.insert(record);
    }

    
    public int insertSelective(Student record) {
        return studentMapper.insertSelective(record);
    }

    
    public Student selectByPrimaryKey(Integer studentId) {
        Student student;
        student = redisStudentService.getResObj(studentId);
        if (student == null) {
            student = studentMapper.selectByPrimaryKey(studentId);
            if (student != null) {
                redisStudentService.cacheResObj(studentId,student);
            }
        }

        return student;
    }

    
    public int updateByPrimaryKeySelective(Student record) {
        return studentMapper.updateByPrimaryKeySelective(record);
    }

    
    public int updateByPrimaryKey(Student record) {
        return studentMapper.updateByPrimaryKey(record);
    }

    public  List<Student> selectByAll( Student student){ return studentMapper.selectByAll(student);};
}
